package cn.miui.mall.controller;

import cn.miui.mall.dao.colordao;
import cn.miui.mall.dao.imagedao;
import cn.miui.mall.dao.selectedtypedao;
import cn.miui.mall.pojo.product_details;
import cn.miui.mall.pojo.selected_color;
import cn.miui.mall.pojo.selected_image;
import cn.miui.mall.pojo.selected_type;
import cn.miui.mall.service.Detailsservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/Details")
public class DetailsController {
    @Autowired
    private Detailsservice detailsservice;
    @Autowired
    private selectedtypedao typedao;
    @Autowired
    private imagedao imagedao;
    @Autowired
    private colordao colordao;
    @RequestMapping("/xiangqing")
    public ModelAndView xiangqing(Integer id,Map<String, Object> map){
        product_details details=detailsservice.findbyid(id);
        map.put("details",details);
        List<selected_type> selectedTypeList=typedao.findBydetailsid(details.getGoodsID());
        map.put("selectedTypeList",selectedTypeList);
        map.put("imageList",imagedao.findAll());
        return new ModelAndView("xiangqing",map);
    }
    @RequestMapping("/yanse")
    public List<selected_color> yanse(Integer id){
        List<selected_color> selectedImageList=colordao.selectedtypeid(id);
        return selectedImageList;
    }
}
